package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsStreamStudio;
import com.scau402.system.service.IWmsStreamStudioService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 直播间Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/studio")
public class WmsStreamStudioController extends BaseController
{
    @Autowired
    private IWmsStreamStudioService wmsStreamStudioService;

    /**
     * 查询直播间列表
     */
    @PreAuthorize("@ss.hasPermi('system:studio:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsStreamStudio wmsStreamStudio)
    {
        startPage();
        List<WmsStreamStudio> list = wmsStreamStudioService.selectWmsStreamStudioList(wmsStreamStudio);
        return getDataTable(list);
    }

    /**
     * 导出直播间列表
     */
    @PreAuthorize("@ss.hasPermi('system:studio:export')")
    @Log(title = "直播间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsStreamStudio wmsStreamStudio)
    {
        List<WmsStreamStudio> list = wmsStreamStudioService.selectWmsStreamStudioList(wmsStreamStudio);
        ExcelUtil<WmsStreamStudio> util = new ExcelUtil<WmsStreamStudio>(WmsStreamStudio.class);
        util.exportExcel(response, list, "直播间数据");
    }

    /**
     * 获取直播间详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:studio:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsStreamStudioService.selectWmsStreamStudioById(id));
    }

    /**
     * 新增直播间
     */
    @PreAuthorize("@ss.hasPermi('system:studio:add')")
    @Log(title = "直播间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsStreamStudio wmsStreamStudio)
    {
        wmsStreamStudio.setCreateBy(getUsername());
        return toAjax(wmsStreamStudioService.insertWmsStreamStudio(wmsStreamStudio));
    }

    /**
     * 修改直播间
     */
    @PreAuthorize("@ss.hasPermi('system:studio:edit')")
    @Log(title = "直播间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsStreamStudio wmsStreamStudio)
    {
        return toAjax(wmsStreamStudioService.updateWmsStreamStudio(wmsStreamStudio));
    }

    /**
     * 删除直播间
     */
    @PreAuthorize("@ss.hasPermi('system:studio:remove')")
    @Log(title = "直播间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsStreamStudioService.deleteWmsStreamStudioByIds(ids));
    }
}
